<?php

	require_once(dirname(__FILE__) . "/../core/safeParam.php");
	require_once '../core/database.php';
	require_once '../core/functions.php';
	
	global $database;
	
	$destacado = $database->select("SELECT * FROM config WHERE id='". ARID ."' ");
	
	if($_POST['hayDatos'] == 1){
		$cbRid			= $_POST['rid'];
    	$showSiteDocs	= $_POST['cb-global-sitedocs'];
    	
    	$check_areas = $database->select("SELECT * FROM options WHERE name='cb-global-sitedocs' AND rid='". $cbRid ."'");
    	$id = $check_areas[0]['id'];

		updateOption("cb-global-sitedocs", $showSiteDocs, $id);
		
		$destacado = array();
		$destacado['pizza_builder'] = $_POST['pizza_builder'];
		$database->update_array("config", $destacado, "id=". $cbRid ."");
	}
	
?> 

<script type="text/javascript" >
	function enviarDatos(){
		document.getElementById("hayDatos").value = 1;
	}
</script>

 	
<form action="" method="POST"> 
	<div class="contenedorConfigMain">
  		<input type="hidden" name="rid" value="<?php echo ARID; ?>" />
  		<input type="hidden" id="hayDatos" name="hayDatos" value="0"> 
  				
		<div class="celdaContenedorConfigMain">
			<div class="opcionConfigMain">
				<?php $item = 'cb-global-sitedocs'; ?>
				Mostar en las búsquedas:
				<select name="cb-global-sitedocs" class="selectConfigMainSiNo" />
           		<option value="1" <?php if (getOption($item, ARID) == 1) { echo 'selected="selected"'; } ?>>Si</option>
           		<option value="0"  <?php if (getOption($item, ARID) == 0) { echo 'selected="selected"'; } ?>>No</option>
         	</select>
			</div>
		</div>
		
		<div class="celdaContenedorConfigMain">
			<div class="opcionConfigMain">
				Destacado:
        		<select name="pizza_builder" class="selectConfigMainSiNo">
           		<option value="1" <?php if ($destacado[0]['pizza_builder'] == 1) { echo 'selected="selected"'; } //$results['pizza_builder'] == 1 ?> >Si</option>
           		<option value="0"  <?php if ($destacado[0]['pizza_builder'] == 0) { echo 'selected="selected"'; } //$results['pizza_builder'] == 0 ?> >No</option>
         	</select>
			</div>
		</div>
		
	<div class="botonConfigMain">
		<input type="submit" value="Guardar" onclick="enviarDatos();">
	</div>
</form>
